import QtQuick
import QtQuick.Controls
import QtQuick3D
import QtQuick3D.Helpers

import QtQuickRO

import "../GameView"
import "../Scene"
import "../Character"
import "../Levels"
import "../framework"
import "../GameMode"
import "../PlayerController"
import "../Actors"

Item {
    property Network network
    anchors.fill: parent
    DefaultGameView {
        id:gameView
        anchors.fill: parent

        environment: ExtendedSceneEnvironment {
            id: environment
            depthOfFieldFocusRange: 800
            depthOfFieldFocusDistance: 400
            depthOfFieldEnabled: true
            lensFlareEnabled: false
            vignetteColor: "#5e5e5e"
            vignetteEnabled: true
            glowLevel: ExtendedSceneEnvironment.GlowLevel.One
            glowBlendMode: ExtendedSceneEnvironment.GlowBlendMode.Additive
            glowBloom: 0.19914
            glowIntensity: 0.48127
            glowStrength: 1
            glowEnabled: true
            aoStrength: 100
            aoDither: false
            aoSampleRate: 4
            aoDistance: 200
            antialiasingMode: SceneEnvironment.NoAA
            backgroundMode: SceneEnvironment.SkyBox
            aoEnabled: true
            lightProbe: Texture {

                textureData: ProceduralSkyTextureData {
                }
            }
        }

        importScene: scene
        camera: controllers.currentCharacter?controllers.currentCharacter.camera:null
    }

    RayPicker{
        id:rayPicker

        view: gameView
    }

    DefaultGameMode{
        id:gameMode
        characterSpawner: scene.playerSpawner
        playerControllerComp:contollerComp
    }

    InputComponent{//输入组件
            id:inputComp
            mainMouseArea: gameView.inputMouseArea
    }

    Item{//所有控制器的存放点
        id:controllers

        property PlayerController currentController//当前客户端对应的控制器
        property Character currentCharacter:currentController?currentController.pawn:null//当前客户端对应的角色
    }

    Component{
        id:contollerComp

        FirstPlayerController{
            id:controller
            parent:controllers
            property alias playerId:shared.playerId
            ROSharedObject{
                id:shared
                property int playerId:0
            }

            Binding{
                target: controllers
                property:"currentController"
                value:controller
                when:network?playerId === network.currentPlayerId:false
            }

            //将输入组件给予当前主机对应的角色控制器
            input:controllers.currentController === controller?inputComp:null
        }

    }

    HomeScene {
        id: scene

        characterComp:FirstCharactor{
            //玩家角色
            id:character
        }

        // property alias characterComp: characterComp
        PerspectiveCamera {
            id: perspectiveCamera
            x: 601.588
            y: 257.946
            z: 1441.74304
        }
    }

    Item {
        id: __materialLibrary__
    }
}

/*##^##
Designer {
    D{i:0}D{i:5;cameraSpeed3d:25;cameraSpeed3dMultiplier:1}
}
##^##*/

